package com.dgut.legalservice.service.impl;

import com.dgut.legalservice.dao.IProcess;
import com.dgut.legalservice.domain.Approval;
import com.dgut.legalservice.domain.Process;
import com.dgut.legalservice.service.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
@Service
public class ProcessServiceImpl implements ProcessService {
    @Autowired
    private IProcess processDao;

    @Override
    public int setStatus(Process process, Integer orderId) {
        Example example = new Example(Approval.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("orderId",orderId);
        List<Process> processList = processDao.selectByExample(example);
        int i;
        if (processList.size()==0){
            processDao.insertSelective(process);
        }else {
            Example example1 = new Example(Process.class);
             processDao.updateByExampleSelective(process,example1);
        }
        return process.getId();
    }
}
